module top(
           input clk,
           input [7: 0] cin_a,
           input [7: 0] cin_b,
           output reg [7: 0] sum,
           output count
       );
reg cout_1;
reg [3: 0] cout_l_sum;
reg [5: 0] cout_h;
reg [5: 0] cout_h_1;

always@(posedge clk)
	begin
		{cout_1, cout_l_sum} <= cin_a[3: 0] + cin_b[3: 0];
	end

assign count = cout_h >> 4;
always@(posedge clk)
	begin
		cout_h <= (cout_1 == 1) ? (cin_a[7 : 4] + cin_b[7 : 4] + cout_1) : cout_h_1;
		cout_h_1 <= (cin_a[7: 4] + cin_b[7: 4]);
		sum <= {cin_a[7: 4] + cin_b[7: 4] + cout_1, cout_l_sum};
	end

endmodule
